'''
Created on Jul 13, 2010

@author: riche
'''

class Directory(object):
    '''
    classdocs
    '''

    def __init__(self):
        '''
        Constructor
        '''
        self.entries = {}
        self.groups = {}
        self.package_root = '/'
    
    def add_entry_object(self, de):
        self.entries[de.short_name] = de
        
    def add_entry(self, name, addr, port):
        de = DirectoryEntry(name, addr, port)
        self.add_entry_object(de)
        pass
        
    def add_group(self, group_name):
        self.groups[group_name] = []
        
    def add_entry_to_group(self, de_name, group_name):
        de = self.get_entry(de_name)
        self.groups[group_name].append(de)
            
    def get_group(self, group_name):
        return self.groups[group_name]
    
    def address(self, name):
        return self.entries[name].address

    def listen_port(self, name):
        return self.entries[name].listen_port
    
    def get_entry(self, name):
        return self.entries[name]
    
    def add_root(self, path):
        return self.package_root + path

class DirectoryEntry(object):
    
    def __init__(self, short_name, address, listen_port):
        self.short_name = short_name
        self.address = address
        self.listen_port = listen_port     